package com.shelpe.services.sustainer.autoDrive;

import org.springframework.batch.core.StepExecution;
import org.springframework.batch.core.step.AbstractStep;
import org.springframework.beans.factory.annotation.Autowired;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class InprogressRegisterStep extends AbstractStep {

	@Autowired
	private InprogressJobs inprogressJobs;
	
	@Override
	protected void doExecute(StepExecution stepExecution) throws Exception {
		String jobName = stepExecution.getJobExecution().getJobInstance().getJobName();
		String instanceID = stepExecution.getJobExecution().getJobInstance().getInstanceId() + "";
		log.info("instance {} is joining the job {}", instanceID, jobName);
		this.inprogressJobs.registerInstance(jobName, instanceID);
	}

}
